<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Theron: THERON_DECLARE_REGISTERED_MESSAGE</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Theron
   &#160;<span id="projectnumber">6.00.02</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_856524284ebe840938865dc061f982fb.html">Include</a></li><li class="navelem"><a class="el" href="dir_7c463a385af7963c97ef4a23e37c5d06.html">Theron</a></li><li class="navelem"><a class="el" href="Register_8h.html">Register.h</a></li>  </ul>
</div>
</div><!-- top -->
<div class="contents">
<table cellspacing="0" cellpadding="0" border="0">
  <tr>
   <td valign="top">
      <div class="navtab">
        <table>
          <tr><td class="navtab"><a class="qindexHL" href="Register_8h_a1832f26f0718ae89c9842ef7ad2c9a73.html#a1832f26f0718ae89c9842ef7ad2c9a73">THERON_DECLARE_REGISTERED_MESSAGE</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="Register_8h_a58d283d4e902a4cb14a4ebae5de25a1e.html#a58d283d4e902a4cb14a4ebae5de25a1e">THERON_DEFINE_REGISTERED_MESSAGE</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="Register_8h_a2f276fc03341ad1dd51b82662b55fd6b.html#a2f276fc03341ad1dd51b82662b55fd6b">THERON_REGISTER_MESSAGE</a></td></tr>
        </table>
      </div>
   </td>
   <td valign="top" class="mempage">
<a class="anchor" id="a1832f26f0718ae89c9842ef7ad2c9a73"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THERON_DECLARE_REGISTERED_MESSAGE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">MessageType</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"><span class="keyword">namespace </span>Theron                                                            \</div>
<div class="line">{                                                                           \</div>
<div class="line">namespace Detail                                                            \</div>
<div class="line">{                                                                           \</div>
<div class="line">template &lt;&gt;                                                                 \</div>
<div class="line">struct MessageTraits&lt;MessageType&gt;                                           \</div>
<div class="line">{                                                                           \</div>
<div class="line">    static <span class="keyword">const</span> <span class="keywordtype">bool</span> HAS_TYPE_NAME = <span class="keyword">true</span>;                                 \</div>
<div class="line">    static <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">const</span> TYPE_NAME;                                     \</div>
<div class="line">};                                                                          \</div>
<div class="line">}                                                                           \</div>
<div class="line">}</div>
</div><!-- fragment -->
<p>Declaration macro for registered message types. </p>
<p>Registers message types for use within <a class="el" href="namespaceTheron.html" title="Main namespace containing all public API components. ">Theron</a>. This macro can be used to register message types together with <a class="el" href="Register_8h_a58d283d4e902a4cb14a4ebae5de25a1e.html#a58d283d4e902a4cb14a4ebae5de25a1e">THERON_DEFINE_REGISTERED_MESSAGE</a>. Together they replace <a class="el" href="Register_8h_a2f276fc03341ad1dd51b82662b55fd6b.html#a2f276fc03341ad1dd51b82662b55fd6b">THERON_REGISTER_MESSAGE</a>, which is deprecated.</p>
<p>Use this macro in combination with THERON_DEFINE_REGISTERED_MESSAGE to separate the declaration of message registration from its definition. This avoids multiple registrations of the same message type, in builds where the same message type header is included into multiple source files. The idea is to use THERON_DECLARE_REGISTERED_MESSAGE in the header and THERON_DEFINE_REGISTERED_MESSAGE in a single, corresponding, source file.</p>
<p>Registration of message types is optional, in general, but required, for message types that are to be sent to remote actors over the network.</p>
<p>Registering the message types used in an application causes <a class="el" href="namespaceTheron.html" title="Main namespace containing all public API components. ">Theron</a> to use hand-rolled Runtime Type Information (RTTI) explicitly stored with each message type, instead of the built-in C++ RTTI.</p>
<p>Doing so allows the built-in C++ RTTI to be turned off, resulting in a memory storage saving in all types, not just message types. This saving can be important in embedded and real-time applications such as games, where for example a Vector class may need to be stored as just three floats, with no additional runtime type information added silently by the compiler.</p>
<p>Another useful benefit is the avoidance of the C++ dynamic_cast operator, which is often slow in many compilers. When THERON_REGISTER_MESSAGE is used, <a class="el" href="namespaceTheron.html" title="Main namespace containing all public API components. ">Theron</a> rolls its own type ID system, and its own type ID checking is significantly faster than dynamic_cast. (Looking at the compiled code for dynamic_cast in Visual Studio, for example, it's hard to imagine how it can be so long).</p>
<p>An important limitation of the message type registration macros is that they can only be used from within the global namespace. Furthermore the full name of the message type must be given, including all namespace scoping. (This means that it isn't generally possible to register messages immediately after their declaration, as we'd often prefer).</p>
<div class="fragment"><div class="line"><span class="keyword">namespace </span>MyNamespace</div>
<div class="line">{</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>MyMessage</div>
<div class="line">{</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><a class="code" href="Register_8h_a1832f26f0718ae89c9842ef7ad2c9a73.html#a1832f26f0718ae89c9842ef7ad2c9a73">THERON_DECLARE_REGISTERED_MESSAGE</a>(MyNamespace::MyMessage);</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"><span class="comment">// In the corresponding .cpp file</span></div>
<div class="line"><a class="code" href="Register_8h_a58d283d4e902a4cb14a4ebae5de25a1e.html#a58d283d4e902a4cb14a4ebae5de25a1e">THERON_DEFINE_REGISTERED_MESSAGE</a>(MyNamespace::MyMessage);</div>
</div><!-- fragment --><p>If message types are registered, then <em>all</em> message types must be registered, throughout the whole application, otherwise runtime errors will occur. Therefore it is simpler and less error prone to not register any message types at all. Only bother with message registration if you specifically need to turn the built-in C++ RTTI system off. If you decide to register your message types, you can turn on message registration checking, which helps to detect unregistered message types. Define <a class="el" href="Defines_8h_a45f62d8604cbbe0e0760ea1bf29d76a5.html#a45f62d8604cbbe0e0760ea1bf29d76a5">THERON_ENABLE_MESSAGE_REGISTRATION_CHECKS</a> as 1 globally in your build, ideally via build settings.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="Register_8h_a58d283d4e902a4cb14a4ebae5de25a1e.html#a58d283d4e902a4cb14a4ebae5de25a1e" title="Definition macro for registered message types. ">THERON_DEFINE_REGISTERED_MESSAGE</a> </dd></dl>

</div>
</div>
    </td>
  </tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
